*********************
* Preparing dataset *
*********************

set more off

* Wallonia

insheet using "/Users/damienbol/Dropbox/MEDW Belgium Survey/paper satisfaction with democracy/New data/elect_be 2/Wallonie_pref.csv", clear case

keep Q10* AGE GEND EDUC Q1A_BEGINNING Q1A_END Q1B_BEGINNING Q1B_END PQ1A_BEGINNING PQ1A_END PQ1B_BEGINNING PQ1B_END Q17* Q18 Q30A* PQ5_1 PQ5_2 PQ6A PQ6B npref* nwin vote_head nwin_below winning* losing* CMPFEDREGION PenetrationPrefVotes*

gen region=1

gen npref_tit2=real(npref_tit)
drop npref_tit
rename npref_tit2 npref_tit

gen nwin2=real(nwin)
drop nwin
rename nwin2 nwin

gen nwin_below2=real(nwin_below)
drop nwin_below
rename nwin_below2 nwin_below

gen winning_close2=real(winning_close)
drop winning_close
rename winning_close2 winning_close

gen winning_open2=real(winning_open)
drop winning_open
rename winning_open2 winning_open

gen losing_close2=real(losing_close)
drop losing_close
rename losing_close2 losing_close

gen losing_open2=real(losing_open)
drop losing_open
rename losing_open2 losing_open

* Flanders

save "/Users/damienbol/Dropbox/MEDW Belgium Survey/paper satisfaction with democracy/New data/WallMEDW_cleaned.dta", replace

insheet using "/Users/damienbol/Dropbox/MEDW Belgium Survey/paper satisfaction with democracy/New data/elect_be 2/Flandre_pref.csv", clear case

keep AGE GEND EDUC Q10* Q1A_BEGINNING Q1A_END Q1B_BEGINNING Q1B_END PQ1A_BEGINNING PQ1A_END PQ1B_BEGINNING PQ1B_END Q17* Q18 Q30A* PQ5_1 PQ5_2 PQ6A PQ6B npref* nwin vote_head nwin_below winning* losing* CMPFEDREGION PenetrationPrefVotes*
gen region=2

gen npref_tit2=real(npref_tit)
drop npref_tit
rename npref_tit2 npref_tit

gen nwin2=real(nwin)
drop nwin
rename nwin2 nwin

gen nwin_below2=real(nwin_below)
drop nwin_below
rename nwin_below2 nwin_below

gen winning_close2=real(winning_close)
drop winning_close
rename winning_close2 winning_close

gen winning_open2=real(winning_open)
drop winning_open
rename winning_open2 winning_open

gen losing_close2=real(losing_close)
drop losing_close
rename losing_close2 losing_close

gen losing_open2=real(losing_open)
drop losing_open
rename losing_open2 losing_open

* Brussels

save "/Users/damienbol/Dropbox/MEDW Belgium Survey/paper satisfaction with democracy/New data/FlanMEDW_cleaned.dta", replace

insheet using "/Users/damienbol/Dropbox/MEDW Belgium Survey/paper satisfaction with democracy/New data/elect_be 2/Bruxelles_pref.csv", clear case

keep AGE GEND EDUC Q10* Q1A_BEGINNING Q1A_END Q1B_BEGINNING Q1B_END PQ1A_BEGINNING PQ1A_END PQ1B_BEGINNING PQ1B_END Q17* Q18 Q30A* PQ5_1 PQ5_2 PQ6A PQ6B npref* nwin vote_head nwin_below winning* losing* PenetrationPrefVotes*
gen region=3
gen CMPFEDREGION=1

save "/Users/damienbol/Dropbox/MEDW Belgium Survey/paper satisfaction with democracy/New data/BruxMEDW_cleaned.dta", replace

append using "/Users/damienbol/Dropbox/MEDW Belgium Survey/paper satisfaction with democracy/New data/WallMEDW_cleaned.dta"
append using "/Users/damienbol/Dropbox/MEDW Belgium Survey/paper satisfaction with democracy/New data/FlanMEDW_cleaned.dta"

save "/Users/damienbol/Dropbox/MEDW Belgium Survey/paper satisfaction with democracy/New data/BelgMEDW_cleaned.dta", replace

********************
* Creating variables
********************

* Satisfaction (pre, post)
**************************

gen satis_pre=.
replace satis_pre=Q1A_BEGINNING
replace satis_pre=Q1A_END if satis_pre==.
replace satis_pre=. if satis_pre==99

gen satis_post=.
replace satis_post=PQ1A_BEGINNING
replace satis_post=PQ1A_END if satis_post==.
replace satis_post=. if satis_post==99

drop if satis_pre==.
drop if satis_post==.

gen satis_diff=satis_post-satis_pre

* Vote choice
*************

drop if PQ6A==.
drop if PQ6B==.
drop if PQ6A==.
drop if PQ6B==.
drop if PQ6B==98
drop if PQ6A==98
drop if PQ6B==27 & region==2

gen vote_post=.
replace vote_post=0 if PQ5_1==1
replace vote_post=0 if PQ5_1==2
replace vote_post=0 if PQ5_1==3
replace vote_post=0 if PQ5_2==2
replace vote_post=0 if PQ6A==99
replace vote_post=0 if PQ6A==999

replace vote_post=1 if PQ6A==1 & region==1
replace vote_post=2 if PQ6A==2 & region==1
replace vote_post=3 if PQ6A==3 & region==1
replace vote_post=4 if PQ6A==4 & region==1
replace vote_post=5 if PQ6A==5 & region==1
replace vote_post=6 if PQ6A==6 & region==1
replace vote_post=7 if PQ6A==7 & region==1
replace vote_post=7 if PQ6A==20 & region==1
replace vote_post=99 if vote_post==. & region==1

replace vote_post=8 if PQ6A==9 & region==2
replace vote_post=9 if PQ6A==10 & region==2
replace vote_post=10 if PQ6A==11 & region==2
replace vote_post=11 if PQ6A==12 & region==2
replace vote_post=12 if PQ6A==13 & region==2
replace vote_post=13 if PQ6A==14 & region==2
replace vote_post=99 if vote_post==. & region==2

replace vote_post=1 if PQ6A==1 & region==3
replace vote_post=2 if PQ6A==2 & region==3
replace vote_post=3 if PQ6A==3 & region==3
replace vote_post=4 if PQ6A==4 & region==3
replace vote_post=5 if PQ6A==5 & region==3
replace vote_post=6 if PQ6A==6 & region==3
replace vote_post=7 if PQ6A==7 & region==3
replace vote_post=8 if PQ6A==9 & region==3
replace vote_post=9 if PQ6A==10 & region==3
replace vote_post=10 if PQ6A==11 & region==3
replace vote_post=11 if PQ6A==12 & region==3
replace vote_post=12 if PQ6A==13 & region==3
replace vote_post=13 if PQ6A==14 & region==3
replace vote_post=99 if vote_post==. & region==3


* Appendix 1 and Footnote 6**************************
tab vote_post if vote_post>0
tab vote_post
sum satis_post satis_pre satis_diff if vote_post==99
sum satis_post satis_pre satis_diff if vote_post==0
****************************************************

* Socio-demographcis
********************

gen age=AGE
gen educ=EDUC
gen gend=GEND

* Number of losing preference votes
***********************************

gen nloose=.
replace nloose=npref-nwin

* At least one win/lost
***********************

gen nwin_dum=0
gen nloose_dum=0
replace nwin_dum=1 if nwin>0
replace nloose_dum=1 if nloose>0

* Categories of winners/losers
******************************

gen npref2=npref
replace npref2=2 if npref2>2

gen nwin2=nwin
replace nwin2=2 if nwin>2

gen nloose2=nloose
replace nloose2=2 if nloose>2

* Preference voting score
**************************

gen pref_score_max=.
replace pref_score_max=max(PenetrationPrefVotesList_1, PenetrationPrefVotesList_2, PenetrationPrefVotesList_3, PenetrationPrefVotesList_4, PenetrationPrefVotesList_5, PenetrationPrefVotesList_6, PenetrationPrefVotesList_7, PenetrationPrefVotesList_8, PenetrationPrefVotesList_9, PenetrationPrefVotesList_10, PenetrationPrefVotesList_11, PenetrationPrefVotesList_12, PenetrationPrefVotesList_13, PenetrationPrefVotesList_14, PenetrationPrefVotesList_15, PenetrationPrefVotesList_16, PenetrationPrefVotesList_17, PenetrationPrefVotesList_18)
replace pref_score_max=PenetrationPrefVotesList_w if npref<1
replace pref_score_max=0 if pref_score_max==.

gen pref_score_dum=0
replace pref_score_dum=1 if pref_score_max>.25

gen pref_score_dum2=0
replace pref_score_dum2=1 if pref_score_max>.1995

* Voting for a big party
************************

gen big_party=0
replace big_party=1 if vote_post==1
replace big_party=1 if vote_post==2
replace big_party=1 if vote_post==3
replace big_party=1 if vote_post==4

replace big_party=1 if vote_post==8
replace big_party=1 if vote_post==9
replace big_party=1 if vote_post==10
replace big_party=1 if vote_post==11
replace big_party=1 if vote_post==13

* Seat share national level
***************************

gen seat_share_nat=.
replace seat_share_nat=0 if vote_post==99 
replace seat_share_nat=0 if vote_post==0

replace seat_share_nat=23 if vote_post==1 
replace seat_share_nat=20 if vote_post==2
replace seat_share_nat=9 if vote_post==3
replace seat_share_nat=6 if vote_post==4 
replace seat_share_nat=2 if vote_post==5 
replace seat_share_nat=2 if vote_post==6 
replace seat_share_nat=1 if vote_post==7 
replace seat_share_nat=33 if vote_post==8
replace seat_share_nat=18 if vote_post==9
replace seat_share_nat=14 if vote_post==10
replace seat_share_nat=13 if vote_post==11 
replace seat_share_nat=3 if vote_post==12 
replace seat_share_nat=6 if vote_post==13

replace seat_share_nat=seat_share_nat/150

* Seat share local level
*************************

gen seat_share_local=.
replace seat_share_local=1 if vote_post==1 & region==1 & CMPFEDREG==1
replace seat_share_local=3 if vote_post==2 & region==1 & CMPFEDREG==1
replace seat_share_local=0 if vote_post==3 & region==1 & CMPFEDREG==1
replace seat_share_local=1 if vote_post==4 & region==1 & CMPFEDREG==1
replace seat_share_local=0 if vote_post==5 & region==1 & CMPFEDREG==1
replace seat_share_local=0 if vote_post==6 & region==1 & CMPFEDREG==1
replace seat_share_local=0 if vote_post==7 & region==1 & CMPFEDREG==1
replace seat_share_local=9 if vote_post==1 & region==1 & CMPFEDREG==2
replace seat_share_local=5 if vote_post==2 & region==1 & CMPFEDREG==2
replace seat_share_local=2 if vote_post==3 & region==1 & CMPFEDREG==2
replace seat_share_local=1 if vote_post==4 & region==1 & CMPFEDREG==2
replace seat_share_local=1 if vote_post==5 & region==1 & CMPFEDREG==2
replace seat_share_local=0 if vote_post==6 & region==1 & CMPFEDREG==2
replace seat_share_local=0 if vote_post==7 & region==1 & CMPFEDREG==2
replace seat_share_local=5 if vote_post==1 & region==1 & CMPFEDREG==3
replace seat_share_local=5 if vote_post==2 & region==1 & CMPFEDREG==3
replace seat_share_local=2 if vote_post==3 & region==1 & CMPFEDREG==3
replace seat_share_local=1 if vote_post==4 & region==1 & CMPFEDREG==3
replace seat_share_local=1 if vote_post==5 & region==1 & CMPFEDREG==3
replace seat_share_local=0 if vote_post==6 & region==1 & CMPFEDREG==3
replace seat_share_local=1 if vote_post==7 & region==1 & CMPFEDREG==3
replace seat_share_local=1 if vote_post==1 & region==1 & CMPFEDREG==4
replace seat_share_local=1 if vote_post==2 & region==1 & CMPFEDREG==4
replace seat_share_local=2 if vote_post==3 & region==1 & CMPFEDREG==4
replace seat_share_local=0 if vote_post==4 & region==1 & CMPFEDREG==4
replace seat_share_local=0 if vote_post==5 & region==1 & CMPFEDREG==4
replace seat_share_local=0 if vote_post==6 & region==1 & CMPFEDREG==4
replace seat_share_local=0 if vote_post==7 & region==1 & CMPFEDREG==4

replace seat_share_local=2 if vote_post==1 & region==1 & CMPFEDREG==5
replace seat_share_local=2 if vote_post==2 & region==1 & CMPFEDREG==5
replace seat_share_local=1 if vote_post==3 & region==1 & CMPFEDREG==5
replace seat_share_local=1 if vote_post==4 & region==1 & CMPFEDREG==5
replace seat_share_local=0 if vote_post==5 & region==1 & CMPFEDREG==5
replace seat_share_local=0 if vote_post==6 & region==1 & CMPFEDREG==5
replace seat_share_local=0 if vote_post==7 & region==1 & CMPFEDREG==5

replace seat_share_local=seat_share_local/5 if region==1 & CMPFEDREG==1
replace seat_share_local=seat_share_local/18 if region==1 & CMPFEDREG==2
replace seat_share_local=seat_share_local/15 if region==1 & CMPFEDREG==3
replace seat_share_local=seat_share_local/4 if region==1 & CMPFEDREG==4
replace seat_share_local=seat_share_local/6 if region==1 & CMPFEDREG==5

replace seat_share_local=11 if vote_post==8 & region==2 & CMPFEDREG==1
replace seat_share_local=4 if vote_post==9 & region==2 & CMPFEDREG==1
replace seat_share_local=2 if vote_post==10 & region==2 & CMPFEDREG==1
replace seat_share_local=3 if vote_post==11 & region==2 & CMPFEDREG==1
replace seat_share_local=2 if vote_post==12 & region==2 & CMPFEDREG==1
replace seat_share_local=2 if vote_post==13 & region==2 & CMPFEDREG==1

replace seat_share_local=5 if vote_post==8 & region==2 & CMPFEDREG==2
replace seat_share_local=3 if vote_post==9 & region==2 & CMPFEDREG==2
replace seat_share_local=2 if vote_post==10 & region==2 & CMPFEDREG==2
replace seat_share_local=2 if vote_post==11 & region==2 & CMPFEDREG==2
replace seat_share_local=0 if vote_post==12 & region==2 & CMPFEDREG==2
replace seat_share_local=0 if vote_post==13 & region==2 & CMPFEDREG==2

replace seat_share_local=6 if vote_post==8 & region==2 & CMPFEDREG==3
replace seat_share_local=4 if vote_post==9 & region==2 & CMPFEDREG==3
replace seat_share_local=4 if vote_post==10 & region==2 & CMPFEDREG==3
replace seat_share_local=3 if vote_post==11 & region==2 & CMPFEDREG==3
replace seat_share_local=1 if vote_post==12 & region==2 & CMPFEDREG==3
replace seat_share_local=2 if vote_post==13 & region==2 & CMPFEDREG==3
replace seat_share_local=5 if vote_post==8 & region==2 & CMPFEDREG==4
replace seat_share_local=3 if vote_post==9 & region==2 & CMPFEDREG==4
replace seat_share_local=4 if vote_post==10 & region==2 & CMPFEDREG==4
replace seat_share_local=2 if vote_post==11 & region==2 & CMPFEDREG==4
replace seat_share_local=0 if vote_post==12 & region==2 & CMPFEDREG==4
replace seat_share_local=1 if vote_post==13 & region==2 & CMPFEDREG==4
replace seat_share_local=6 if vote_post==8 & region==2 & CMPFEDREG==5
replace seat_share_local=4 if vote_post==9 & region==2 & CMPFEDREG==5
replace seat_share_local=2 if vote_post==10 & region==2 & CMPFEDREG==5
replace seat_share_local=3 if vote_post==11 & region==2 & CMPFEDREG==5
replace seat_share_local=0 if vote_post==12 & region==2 & CMPFEDREG==5
replace seat_share_local=1 if vote_post==13 & region==2 & CMPFEDREG==5

replace seat_share_local=seat_share_local/24 if region==2 & CMPFEDREG==1
replace seat_share_local=seat_share_local/12 if region==2 & CMPFEDREG==2
replace seat_share_local=seat_share_local/20 if region==2 & CMPFEDREG==3
replace seat_share_local=seat_share_local/15 if region==2 & CMPFEDREG==4
replace seat_share_local=seat_share_local/16 if region==2 & CMPFEDREG==5

replace seat_share_local=5 if vote_post==1 & region==3
replace seat_share_local=4 if vote_post==2 & region==3
replace seat_share_local=2 if vote_post==3 & region==3
replace seat_share_local=2 if vote_post==4 & region==3
replace seat_share_local=0 if vote_post==5 & region==3
replace seat_share_local=2 if vote_post==6 & region==3
replace seat_share_local=0 if vote_post==7 & region==3
replace seat_share_local=0 if vote_post==8 & region==3
replace seat_share_local=0 if vote_post==9 & region==3
replace seat_share_local=0 if vote_post==10 & region==3
replace seat_share_local=0 if vote_post==11 & region==3
replace seat_share_local=0 if vote_post==12 & region==3
replace seat_share_local=0 if vote_post==13 & region==3

replace seat_share_local=seat_share_local/15 if region==3

replace seat_share_local=0 if vote_post==99 
replace seat_share_local=0 if vote_post==0 

* District magnitude
********************
gen dm=.
replace dm=5 if CMPFEDREGION==1 & region==1
replace dm=18 if CMPFEDREGION==2 & region==1
replace dm=15 if CMPFEDREGION==3 & region==1
replace dm=4 if CMPFEDREGION==4 & region==1
replace dm=6 if CMPFEDREGION==5 & region==1

replace dm=24 if CMPFEDREGION==1 & region==2
replace dm=12 if CMPFEDREGION==2 & region==2
replace dm=20 if CMPFEDREGION==3 & region==2
replace dm=15 if CMPFEDREGION==4 & region==2
replace dm=16 if CMPFEDREGION==5 & region==2

replace dm=15 if region==3

* Voting for the party-list
***************************

gen party_vote=1
replace party_vote=0 if npref>0

gen preference_vote=1
replace preference_vote=0 if npref==0

* Political knowledge
*********************

gen knowledge_fr=0
gen knowledge_nl=0

replace knowledge_nl=knowledge_nl+1 if Q10A==6 & vote_post>7
replace knowledge_fr=knowledge_fr+1 if Q10B==8 & vote_post<8
replace knowledge_nl=knowledge_nl+1 if Q10C==2 & vote_post>7
replace knowledge_fr=knowledge_fr+1 if Q10D==4 & vote_post<8
replace knowledge_nl=knowledge_nl+1 if Q10E==10 & vote_post>7

gen knowledge2=0
replace knowledge2=1 if knowledge_fr==2
replace knowledge2=1 if knowledge_nl==3

**********
* Analyses
**********

* Dropping missing values
*************************

drop if seat_share_local==.
drop if vote_post==0

drop if npref==.
drop if nwin==.
drop if vote_post==99

* Descriptives
***************

sum satis_pre satis_post satis_diff

bysort npref2: sum satis_pre satis_post satis_diff
bysort nwin2: sum satis_pre satis_post satis_diff
bysort nloose2: sum satis_pre satis_post satis_diff

* Regressions
**************

reg satis_diff i.preference_vote npref satis_pre age gend educ i.vote_post seat_share_local dm
outreg2 using "/Users/damienbol/Desktop/table2.doc", se dec(2) alpha(0.05, 0.1) replace

reg satis_diff i.nwin2 i.nloose2 npref satis_pre age gend educ i.vote_post seat_share_local dm
outreg2 using "/Users/damienbol/Desktop/table2.doc", se dec(2) alpha(0.05, 0.1) append

reg satis_diff nwin_dum nloose_dum npref satis_pre age gend educ i.vote_post seat_share_local dm
outreg2 using "/Users/damienbol/Desktop/table2.doc", se dec(2) alpha(0.05, 0.1) append

* Quantities of interest
************************

quietly reg satis_diff i.nwin2 i.nloose2 npref satis_pre age gend educ i.vote_post seat_share_local dm
margins, at(nwin2=2 nloose2=0) at(nwin2=0 nloose2=2) atmeans post
test _b[1._at] = _b[2._at]

quietly reg satis_diff i.nwin2 i.nloose2 npref satis_pre age gend educ i.vote_post seat_share_local dm
margins, at(nwin2=0 nloose2=0) at(nwin2=2 nloose2=0) atmeans post
test _b[1._at] = _b[2._at]

quietly reg satis_diff i.nwin2 i.nloose2 npref satis_pre age gend educ i.vote_post seat_share_local dm
margins, at(nwin2=0 nloose2=0) at(nwin2=0 nloose2=2) post
test _b[1._at] = _b[2._at]

* Supplementary analyses
**************************

reg satis_diff pref_score_max i.nwin2 i.nloose2 npref satis_pre age gend educ i.vote_post seat_share_local dm if npref>0 & big_party==1
outreg2 using "/Users/damienbol/Desktop/table4.doc", se dec(2) alpha(0.05, 0.1) replace

reg satis_diff pref_score_dum i.nwin2 i.nloose2 npref satis_pre age gend educ i.vote_post seat_share_local dm if npref>0 & big_party==1
outreg2 using "/Users/damienbol/Desktop/table4.doc", se dec(2) alpha(0.05, 0.1) append

reg satis_diff pref_score_dum2 i.nwin2 i.nloose2 npref satis_pre age gend educ i.vote_post seat_share_local dm if npref>0 & big_party==1
outreg2 using "/Users/damienbol/Desktop/table4.doc", se dec(2) alpha(0.05, 0.1) append

* Marginsplot
*************

sum pref_score_max if npref>0
tab pref_score_dum  if npref>0
tab pref_score_dum2  if npref>0

quietly reg satis_diff pref_score_max i.nwin2 i.nloose2 npref satis_pre age gend educ i.vote_post seat_share_local dm if npref>0 & big_party==1
margins, atmeans at(pref_score_max=(0(.05).50))
marginsplot, recast(line) recastci(rarea) title("") graphregion(color(white)) xtitle("Preference score of the voter's preference vote (max)") ytitle("Difference in satisfaction with democracy") scheme(s2mono) xline(.06, lp(dash)) xline(.32, lp(dash)) 

quietly reg satis_diff pref_score_max i.nwin2 i.nloose2 npref satis_pre age gend educ i.vote_post seat_share_local dm if npref>0  & big_party==1
margins, atmeans at(pref_score_max=.06)  at(pref_score_max=0.32) post
test _b[1._at] = _b[2._at]

quietly reg satis_diff pref_score_dum i.nwin2 i.nloose2 npref satis_pre age gend educ i.vote_post seat_share_local dm if npref>0  & big_party==1
margins, atmeans at(pref_score_dum=0)  at(pref_score_dum=1) post
test _b[1._at] = _b[2._at]

quietly reg satis_diff pref_score_dum2 i.nwin2 i.nloose2 npref satis_pre age gend educ i.vote_post seat_share_local dm if npref>0  & big_party==1
margins, atmeans at(pref_score_dum2=0)  at(pref_score_dum2=1) post
test _b[1._at] = _b[2._at]

* Appendix
**********

* Descriptives statistics

tab npref
tab nwin

hist npref, freq title("") graphregion(color(white)) xtitle("Number of preference votes") ytitle("") scheme(s2mono) 
hist nwin, freq bin(10) title("") graphregion(color(white)) xtitle("Number of winning preference votes") ytitle("") scheme(s2mono) 
hist nloose, freq bin(10) title("") graphregion(color(white)) xtitle("Number of losing preference votes") ytitle("") scheme(s2mono) 

bysort vote_post: sum npref

* Predicted values

quietly reg satis_diff i.preference_vote npref satis_pre age gend educ i.vote_post seat_share_local dm
margins, atmeans at(vote_post=(1 2 3 4 5 7 8 9 10 11 12 13)) post
outreg2 using "/Users/damienbol/Desktop/tablea6.doc", se dec(2) alpha(0.05, 0.1) replace

reg satis_diff i.nwin2 i.nloose2 npref satis_pre age gend educ i.vote_post seat_share_local dm
margins, atmeans at(vote_post=(1 2 3 4 5 7 8 9 10 11 12 13)) post
outreg2 using "/Users/damienbol/Desktop/tablea6.doc", se dec(2) alpha(0.05, 0.1) append

reg satis_diff nwin_dum nloose_dum npref satis_pre age gend educ i.vote_post seat_share_local dm
margins, atmeans at(vote_post=(1 2 3 4 5 7 8 9 10 11 12 13)) post
outreg2 using "/Users/damienbol/Desktop/tablea6.doc", se dec(2) alpha(0.05, 0.1) append


* Models with interactions

reg satis_diff i.nwin2##i.knowledge2 i.nloose2##i.knowledge2 npref satis_pre age gend educ i.vote_post seat_share_local dm
outreg2 using "/Users/damienbol/Desktop/tablea7.doc", se dec(2) alpha(0.05, 0.1) append

* Models without head of the list

gen npref_b=npref
replace npref_b=npref-1 if vote_head==1

gen vote_head_win=0
replace vote_head_win=1 if vote_head==1 & seat_share_local>0

gen vote_head_loose=0
replace vote_head_loose=1 if vote_head==1 & seat_share_local==0

gen nwin_b=nwin
replace nwin_b=nwin-1 if vote_head==1 & seat_share_local>0
gen nwin2_b=nwin_b
replace nwin2_b=2 if nwin_b>2

gen nloose_b=nloose
replace nloose_b=nloose-1 if vote_head==1 & seat_share_local==0
gen nloose2_b=nloose_b
replace nloose2_b=2 if nloose_b>2

reg satis_diff vote_head_win vote_head_loose i.nwin2_b i.nloose2_b npref_b satis_pre age gend educ i.vote_post seat_share_local dm
outreg2 using "/Users/damienbol/Desktop/tablea8.doc", se dec(2) alpha(0.05, 0.1) replace






